home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TPUG - Toronto PET Users Group
/
TPUG Users Group CD
/
TPUG Users Group CD.iso
/
C64
/
M-More Monthly Disks
/
(c)m4.d64
/
synth sound.c
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2007-02-04
|
8KB
|
303 lines
1 REM SYNTH SOUND
2 REM ** WRITTEN BY S,A,WATSON **
3 AD=12:SR=12:W=33:HP=0:LP=0:POKE54296,15
4 GOSUB1000:GOSUB3000
6 REM *****************
7 REM * VOICE ROUTINE *
8 REM *****************
9 REM
10 GETK$:IFK$=""THEN10
11 GOSUB100
12 IFK$=""THEN10
13 POKE54276,0
14 POKE54277,AD
15 POKE54278,SR
16 POKE54275,HP:POKE54274,LP
17 POKE54276,W
18 POKE54273,A:POKE54272,B
20 GETK$:IFK$=""THEN20
21 GOSUB100
22 IFK$=""THEN20
23 POKE54283,0
24 POKE54284,AD
25 POKE54285,SR
26 POKE54282,HP:POKE54281,LP
27 POKE54283,W
28 POKE54280,A:POKE54279,B
30 GETK$:IFK$=""THEN30
31 GOSUB100
32 IFK$=""THEN30
33 POKE54290,0
34 POKE54291,AD
35 POKE54292,SR
36 POKE54289,HP:POKE54288,LP
37 POKE54290,W
38 POKE54287,A:POKE54286,B
39 GOTO10
40 REM
41 REM ******************
42 REM * OCTAVE 1 TABLE *
43 REM ******************
44 REM
100 IFO=2THEN200
101 IFO=3THEN300
102 IFO=4THEN400
103 IFK$=""THENPOKE54276,0:POKE54283,0:POKE54290,0:K$="":RETURN
105 IFK$="2"THENO=2:K$="":RETURN
106 IFK$="3"THENO=3:K$="":RETURN
107 IFK$="4"THENO=4:K$="":RETURN
112 IFK$="Z"THENA=28:B=214:RETURN
113 IFK$="X"THENA=32:B=94:RETURN
114 IFK$="C"THENA=34:B=75:RETURN
115 IFK$="V"THENA=38:B=126:RETURN
125 IFK$="B"THENA=43:B=52:RETURN
130 IFK$="N"THENA=45:B=198:RETURN
135 IFK$="M"THENA=51:B=97:RETURN
140 IFK$=","THENA=57:B=172:RETURN
145 IFK$="."THENA=64:B=188:RETURN
150 IFK$="/"THENA=68:B=149:RETURN
151 REM
152 REM ** SHARPS **
153 REM
154 IFK$="S"THENA=30:B=141:RETURN
155 IFK$="F"THENA=36:B=85:RETURN
160 IFK$="G"THENA=40:B=200:RETURN
161 IFK$="J"THENA=48:B=127:RETURN
165 IFK$="K"THENA=54:B=111:RETURN
170 IFK$="L"THENA=61:B=126:RETURN
175 IFK$=";"THENA=42:B=169:RETURN
189 IFK$="_"THENGOSUB650
190 IFK$="\"THENGOSUB600
191 IFK$="[133]"THENW=33:K$="":RETURN
192 IFK$="[134]"THENW=17:K$="":RETURN
193 IFK$="[135]"THENW=129:K$="":RETURN
194 IFK$="[136]"THENW=65:K$="":RETURN
195 IFK$=""THENRETURN
196 REM
197 REM ******************
198 REM * OCTAVE 2 TABLE *
199 REM ******************
200 IFK$=""THENPOKE54276,0:POKE54283,0:POKE54290,0:K$="":RETURN
201 IFK$="1"THENO=1:K$="":RETURN
202 IFK$="3"THENO=3:K$="":RETURN
203 IFK$="4"THENO=4:K$="":RETURN
212 IFK$="Z"THENA=14:B=107:RETURN
213 IFK$="X"THENA=16:B=47:RETURN
214 IFK$="C"THENA=17:B=37:RETURN
215 IFK$="V"THENA=19:B=63:RETURN
225 IFK$="B"THENA=21:B=154:RETURN
230 IFK$="N"THENA=22:B=227:RETURN
235 IFK$="M"THENA=25:B=177:RETURN
240 IFK$=","THENA=28:B=214:RETURN
245 IFK$="."THENA=32:B=94:RETURN
250 IFK$="/"THENA=34:B=75:RETURN
251 REM
252 REM ** SHARPS **
253 REM
254 IFK$="S"THENA=15:B=70:RETURN
255 IFK$="F"THENA=18:B=42:RETURN
260 IFK$="G"THENA=20:B=100:RETURN
261 IFK$="J"THENA=24:B=63:RETURN
265 IFK$="K"THENA=27:B=56:RETURN
270 IFK$="L"THENA=30:B=141:RETURN
275 IFK$=";"THENA=36:B=85:RETURN
289 IFK$="_"THENGOSUB650
290 IFK$="\"THENGOSUB600
291 IFK$="[133]"THENW=33:K$="":RETURN
292 IFK$="[134]"THENW=17:K$="":RETURN
293 IFK$="[135]"THENW=129:K$="":RETURN
294 IFK$="[136]"THENW=65:K$="":RETURN
295 IFK$=""THENRETURN
296 REM
297 REM ******************
298 REM * OCTAVE 3 TABLE *
299 REM ******************
300 IFK$=""THENPOKE54276,0:POKE54283,0:POKE54290,0:K$="":RETURN
301 IFK$="1"THENO=1:K$="":RETURN
302 IFK$="2"THENO=2:K$="":RETURN
303 IFK$="4"THENO=4:K$="":RETURN
312 IFK$="Z"THENA=7:B=53:RETURN
313 IFK$="X"THENA=8:B=23:RETURN
314 IFK$="C"THENA=8:B=147:RETURN
315 IFK$="V"THENA=9:B=159:RETURN
325 IFK$="B"THENA=10:B=205:RETURN
330 IFK$="N"THENA=11:B=114:RETURN
335 IFK$="M"THENA=12:B=216:RETURN
340 IFK$=","THENA=14:B=107:RETURN
345 IFK$="."THENA=16:B=47:RETURN
350 IFK$="/"THENA=17:B=37:RETURN
351 REM
352 REM ** SHARPS **
353 REM
354 IFK$="S"THENA=7:B=163:RETURN
355 IFK$="F"THENA=9:B=21:RETURN
360 IFK$="G"THENA=10:B=60:RETURN
361 IFK$="J"THENA=12:B=32:RETURN
365 IFK$="K"THENA=13:B=156:RETURN
370 IFK$="L"THENA=15:B=70:RETURN
375 IFK$=";"THENA=18:B=42:RETURN
389 IFK$="_"THENGOSUB650
390 IFK$="\"THENGOSUB600
391 IFK$="[133]"THENW=33:K$="":RETURN
392 IFK$="[134]"THENW=17:K$="":RETURN
393 IFK$="[135]"THENW=129:K$="":RETURN
394 IFK$="[136]"THENW=65:K$="":RETURN
395 IFK$=""THENRETURN
396 REM
397 REM ******************
398 REM * OCTAVE 4 TABLE *
399 REM ******************
400 IFK$=""THENPOKE54276,0:POKE54283,0:POKE54290,0:K$="":RETURN
401 IFK$="1"THENO=1:K$="":RETURN
402 IFK$="2"THENO=2:K$="":RETURN
403 IFK$="3"THENO=3:K$="":RETURN
412 IFK$="Z"THENA=3:B=155:RETURN
413 IFK$="X"THENA=4:B=12:RETURN
414 IFK$="C"THENA=4:B=73:RETURN
415 IFK$="V"THENA=4:B=208:RETURN
425 IFK$="B"THENA=5:B=103:RETURN
430 IFK$="N"THENA=5:B=185:RETURN
435 IFK$="M"THENA=6:B=108:RETURN
440 IFK$=","THENA=7:B=53:RETURN
445 IFK$="."THENA=8:B=23:RETURN
450 IFK$="/"THENA=8:B=147:RETURN
451 REM
452 REM ** SHARPS **
453 REM
454 IFK$="S"THENA=3:B=210:RETURN
455 IFK$="F"THENA=4:B=139:RETURN
460 IFK$="G"THENA=5:B=25:RETURN
461 IFK$="J"THENA=6:B=16:RETURN
465 IFK$="K"THENA=6:B=206:RETURN
470 IFK$="L"THENA=7:B=163:RETURN
475 IFK$=";"THENA=9:B=21:RETURN
489 IFK$="_"THENGOSUB650
490 IFK$="\"THENGOSUB600
491 IFK$="[133]"THENW=33:K$="":RETURN
492 IFK$="[134]"THENW=17:K$="":RETURN
493 IFK$="[135]"THENW=129:K$="":RETURN
494 IFK$="[136]"THENW=65:K$="":RETURN
495 IFK$=""THENRETURN
496 RETURN
594 REM
595 REM ****************************
596 REM * INSTRUMENT CHANG ROUTINE *
597 REM ****************************
600 REM
602 PRINT"";TAB(34);"[\]"
605 GETQ$:IFQ$=""THEN605
608 PRINT"";TAB(34);" "
610 IFQ$="+"THENAD=12:SR=12:W=33:HP=0:LP=0:K$="":RETURN
620 IFQ$="-"THENAD=9:SR=0:W=65:HP=2:LP=255:K$="":RETURN
630 IFQ$="@"THENAD=24:SR=15:W=17:HP=0:LP=0:K$="":RETURN
640 IFQ$="*"THENAD=135:SR=15:W=17:HP=0:LP=0:K$="":RETURN
641 RETURN
642 REM
643 REM *******************************
644 REM * DEFINABLE INSTRUMENT CHANGE *
645 REM *******************************
650 PRINT"[_]"
651 GETX$:IFX$=""THEN651
652 PRINT" "
655 IFX$="9"THENGOSUB800
660 IFX$>"8"ORX$<"1"THENRETURN
662 X=VAL(X$)
670 AD=AD(X):SR=SR(X):HP=HP(X):LP=LP(X):W=W(X)
671 K$="":RETURN
800 PRINT"[147][215]HAT [201]NSTRUMENT DO YOU WISH TO EXAMINE"
810 INPUT" 1 TO 8 ";DE
820 IFDE>8ORDE<1THENPRINT"[145][145][145]":GOTO810
830 PRINT"[147][212]HE [201]NSTRUMENT YOU WISH TO EXAMINE IS:-"
840 PRINT" ";IN$(DE)
850 PRINT"[201]TS SETTINGS ARE AS FOLLOWS:-"
860 PRINT" [176][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][178][192][192][192][192][192][174]"
870 PRINT" [221][159][193]TTACK/[196]ECAY [221][159]";AD(DE);TAB(31);"[221]"
871 PRINT" [171][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][219][192][192][192][192][192][179]"
872 PRINT" [221][159][211]USTAIN/[210]ELEASE [221][159]";SR(DE);TAB(31);"[221]"
873 PRINT" [171][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][219][192][192][192][192][192][179]"
874 PRINT" [221][159][215]AVEFORM [221][159]";W(DE);TAB(31);"[221]"
875 PRINT" [171][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][219][192][192][192][192][192][179]"
876 PRINT" [221][159][200]IGH [208]ULSE RATE [221][159]";HP(DE);TAB(31);"[221]"
877 PRINT" [171][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][219][192][192][192][192][192][179]"
878 PRINT" [221][159][204]OW [208]ULSE RATE [221][159]";LP(DE);TAB(31);"[221]"
879 PRINT" [173][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][177][192][192][192][192][192][189]"
880 INPUT" [196]O YOU WISH TO REDIFINE([217]/[206])[159]";T$
885 IFT$="Y"THENPRINT"":GOSUB2010
886 IFT$="N"THEN895
887 PRINT"[145][145]":GOTO880
895 GOSUB3000
900 RETURN
990 REM
991 REM ************************
992 REM * PROGRAM INTRODUCTION *
993 REM ************************
998 REM
1000 POKE53280,0:POKE53281,0
1010 PRINT"[147] [200]ELLO AND WELCOME TO"
1020 PRINT"[160] [211][217][206][212][200][197][211][207][213][206][196] 64 "
1030 PRINT"[215]ITH THIS PROGRAM, YOU CAN PLAY ANY ONE"
1040 PRINT"OF FOUR OCTAVES. [217]OU CAN CHANGE OCTAVES"
1050 PRINT"AT ANY TIME WHILE YOU'RE PLAYING BY"
1060 PRINT"PRESSING KEYS [159] 1, 2, 3 OR 4. [212]HERE ARE"
1070 PRINT"ALSO TWELVE SETS OF SOUNDS THAT CAN BE"
1080 PRINT"USED. [197]IGHT OF THESE ARE USER DEFINABLE"
1090 PRINT"AND CAN BE SET UP AT THE START OF THE"
1100 PRINT"PROGRAM, OR REDEFINED WHILE THE PROGRAM"
1110 PRINT"IS RUNNING BY PRESSING KEY '_' & '9'"
1120 INPUT" [197]NTER '[207][195][212][193][214][197]' 1 TO 4 ";O
1125 PRINT""
1130 IFO>4ORO<1THENPRINT"[145][145][145]":GOTO1120
1140 RETURN
2000 REM
2001 REM **************************
2002 REM * DEFINABLE INST' SET UP *
2003 REM **************************
2004 REM
2010 PRINT"[145][145][145][145][145][145][145][145][145][145][145] [197]NTER NAME FOR INSTRUMENT NUMBER ";DE
2020 INPUT" ";IN$(DE)
2030 INPUT"[197]NTER [193]TTACK/[196]ECAY LEVEL(0-255)";AD(DE)
2035 IFAD(DE)>255ORAD(DE)<0THENPRINT"[211]ORRY ";AD(DE);" IS OUT OF RANGE":GOTO2030
2040 INPUT"[197]NTER [211]USTAIN/[210]ELEASE LEVEL(0-255)";SR(DE)
2045 IFSR(DE)>255ORSR(DE)<0THENPRINT"[211]ORRY ";SR(DE);" IS OUT OF RANGE":GOTO2040
2050 INPUT"[197]NTER WAVEFORM [210]EQUIRED ([211]-[212]-[206] OR [208])";W$(DE)
2060 IFW$(DE)="T"THENW(DE)=17:GOTO2990
2065 IFW$(DE)="S"THENW(DE)=33:GOTO2990
2070 IFW$(DE)="N"THENW(DE)=129:GOTO2990
2075 IFW$(DE)="P"THENW(DE)=65:GOTO2100
2080 PRINT"[211]ORRY ";W$(DE);" NOT UNDERSTOOD":GOTO2050
2100 INPUT"[197]NTER THE [200][201] PULSE RATE(0-15)";HP(DE)
2110 IFHP(DE)<0THENPRINT"[211]ORRY, PULSE RATE TOO [204][207][215]":GOTO2100
2120 IFHP(DE)>15THENPRINT"[211]ORRY, PULSE RATE TOO [200][201][199][200]":GOTO2100
2130 INPUT"[197]NTER THE [204][207] PULSE RATE(0-15)";LP(DE)
2140 IFLP(DE)<0THENPRINT"[211]ORRY, PULSE RATE TOO [204][207][207]":GOTO2130
2150 IFLP(DE)>15THENPRINT"[211]ORRY, PULSE RATE TOO [200][201][199][200]":GOTO2130
2990 RETURN
3000 PRINT"[147] "
3010 PRINT" [146] [221] [221] [221] "
3020 PRINT" [146] [221] [221] [221] "
3030 PRINT" [146] [221] [221] [221] "
3040 PRINT" [146] [221] [221] [221] [221] [221] [221] [221] [221] [221] [221] "
3050 PRINT" [146][218][221][216][221][195][221][214][221][194][221][206][221][205][221],[221].[221]/[221] "
3060 PRINT"[176][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][178][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][174]"
3100 PRINT"[221][159][201][206][211][212][210][213][205][197][206][212] [203][197][217][211] [221][159] [207][195][212][193][214][197] [203][197][217] [221]"
3105 PRINT"[171][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][219][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][179]"
3110 PRINT"[221][159][208]IANO \ + [221][159] [198]IRST 1 [221]"
3120 PRINT"[221][159][194]ANJO \ - [221][159] [211]ECOND 2 [221]"
3130 PRINT"[221][159][216]YLOPHONE \ @ [221][159] [212]HIRD 3 [221]"
3140 PRINT"[221][159][215]OODWIND \ * [221][159] [198]OURTH 4 [221]"
3160 FORI=1TO8
3165 IFIN$(I)=""THENIN$(I)="[206]OT [213]SED"
3170 PRINT"[221][159]";IN$(I);TAB(14);"_";I;TAB(19);"[221]";TAB(38);"[221]"
3180 NEXTI
3190 PRINT"[173][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][177][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][189]"
3200 PRINT"[145][145][145][145][145][145][145][145][145]"
3210 PRINTTAB(19)"[171][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][179]"
3220 PRINTTAB(19)"[221][159] [215][193][214][197][198][207][210][205] [203][197][217] [221]"
3230 PRINTTAB(19)"[171][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][179]"
3240 PRINTTAB(21)"[159][211]AWTOOTH F1"
3250 PRINTTAB(21)"[212]RIANGLE F3"
3260 PRINTTAB(21)"[206]OISE F5"
3270 PRINTTAB(21)"[208]ULSE F7"
3280 PRINT" [208]RESS '[158]_[159]' THEN '[158]9[159]' TO RE-DEFINE."
3400 RETURN